<?php 

/**
 * Joomla! 1.5 component arts_curriculum
 * @package    arts_curriculum
 * @subpackage
 * @author     Chris Borkowski {@link http://www.guggenheim.org}
 * @author     Created on 31-August-2009
 */

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' ); 


function searchMessage(){
$search =& JFactory::getURI();
$u =& JFactory::getURI();
$message = $search->getVar('search', 'There are no items to be displayed', 'post','string');

$message = str_replace("-", " ", $message);

if ($message =='exhibitions') {
$message = "Exhibiitons";
	}

return $message;

}

?>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>

<div id="ac_sort_page_box">
  
  <div id="ac_sort_page_title"><!--searchMessage() will place text" -->
	<span id="ac_sort_message"><h4><?php  echo searchMessage(); ?> </h4></span>
   </div>
   
    <?php if (searchMessage() == "Artists") :?>
    	<?php foreach ($this->items as $item) : ?>
   
     	
     	<div id="ac_sort_lesson_box">
      	<div id ="ac_sort_cat_link"><?php echo $item->artist_name_link; ?></div>
     	 </div><!--end ac_sort_lesson_box -->
      <?php endforeach; ?>
    
      
    <?php elseif (searchMessage() == 'Exhibitions') :?>
    
    	<?php foreach ($this->items as $item) : ?>
   
     	
     	<div id="ac_sort_lesson_box">
      	<div id ="ac_sort_cat_link"><?php echo $item->catlink; ?></div>
     	 </div><!--end ac_sort_lesson_box -->
     
     <?php endforeach; ?>
     
     <?php elseif (searchMessage() != '') :?>
     
     <?php foreach ($this->items as $item): ?>
    
		<div id="ac_sort_lesson_box">
			<div id ="ac_sort_cat_link"><?php echo $item->catlink; ?></div>
			<div id ="ac_sort_article_link"><?php echo $item->link; ?></div>
			<!--<p>DEV: <?php echo $item->subject; ?></p> -->
			<div id ="ac_sort_lesson_areas_box">
			<?php    // we need to first determin is were in the subjects array		
					// we need to make a subject/meduim link - this is tricky - we need to break the string items into array then process each array item
					// split the string by the "," delimeter and cast into an array then do an array explode 
				
				$subjects_array = explode(",", $item->subject);
				foreach ($subjects_array as $subjects){
					$sub_conditon= array ('English / Language Arts','Social Studies','Visual Arts','Technology','Math / Sciance');
					if (in_array( $subjects, $sub_conditon )) {
					$sublink = JRoute::_( 'index.php?option=com_arts_curriculum&view=sort&search='.$subjects);
					echo $sublinks = '<a href="'. $sublink .'" class="ac_sort_sub_link">'.$this->escape($subjects).'</a>&nbsp;&nbsp;';
					}
					
				} 
				
				;?>
			</div>
		</div><!--end ac_category_lesson_box -->
    
    <?php endforeach; ?>
 

<?php endif ;?>


</div><!--end ac page box-->

<!-- </td>
     <td valign="top">
		<div id="ac_category_page_right_col">
		<h4>Lessons</h4><br/>
		<?php foreach ($this->items as $item) : ?>
		<!-- here we go let' preg_repace the class -->

		<?php echo preg_replace('/ac_intro_cat_link/','ac_intro_cat_link_right_col', $item->link);?><br/>
		<?php endforeach; ?>
		</div><!--end faux right coll -->
		
     </td> -->
  </tr>
</table>
<from>
<input type="hidden" name="option" value="<?php echo $option;?>" />
<input type="hidden" name="sortby" value="" />
</form>
